package com.example.demo.controller.AuthorControl;

import com.example.demo.entity.BackResponseEntity;
import com.example.demo.entity.requestJson.DeleteReq;
import com.example.demo.entity.requestJson.FuzzyQueryPostReq;
import com.example.demo.entity.responseJson.ListResult;
import com.example.demo.entity.responseJson.QueryPostRes;
import com.example.demo.service.PostService;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author : 洪俊新
 * @date : 2021/3/13 15:05
 * @description:
 */
@RestController
@RequestMapping("/author/post")
@Api(value = "帖子管理接口", tags = "帖子管理接口")
public class PostController {
    @Autowired
    private PostService postService;

    @ApiOperation(value = "查询单独帖子详情", notes = "传postId")
    @ApiOperationSupport(author = "杨")
    @ApiResponses(
            @ApiResponse(code = 200, message = "处理成功")
    )
    @GetMapping("/querypost")
    public BackResponseEntity<List<QueryPostRes>> queryPost(DeleteReq deleteReq){
        return postService.queryPost(deleteReq);
    }

    @ApiOperation(value = "查询作者帖子详情", notes = "传authortId")
    @ApiOperationSupport(author = "杨")
    @ApiResponses(
            @ApiResponse(code = 200, message = "处理成功")
    )
    @GetMapping("/querypostbyauthor")
    public BackResponseEntity<ListResult<List<QueryPostRes>>> queryPostByAuthor(DeleteReq deleteReq){
        return postService.queryPostByAuthor(deleteReq);
    }

    @ApiOperation(value = "模糊查询帖子详情", notes = "传条件")
    @ApiOperationSupport(author = "杨")
    @ApiResponses(
            @ApiResponse(code = 200, message = "处理成功")
    )
    @GetMapping("/fuzzyquerypost")
    public BackResponseEntity<List<QueryPostRes>> fuzzyqueryPost(FuzzyQueryPostReq fuzzyQueryPostReq){
        return postService.fuzzyqueryPost(fuzzyQueryPostReq);
    }
}
